home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreateClipTimeWarp.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.4 KB  |  316 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct 17, 2000
  22. //  Author:         cdt
  23. //
  24. //  Description:
  25. //      This script is the create clip time warp option box
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. proc setOptionVars (int $forceFactorySettings)
  35. {
  36.     //    createClipTimeWarpOptBox:
  37.     //    1 == create an enabled time warp curve
  38.     //    2 == create a disabled time warp curve
  39.     if ($forceFactorySettings || 
  40.         !`optionVar -exists createClipTimeWarpOptBox`) {
  41.         optionVar -intValue createClipTimeWarpOptBox 1;
  42.     }
  43. }
  44.  
  45. //
  46. //  Procedure Name:
  47. //      createClipTimeWarpSetup
  48. //
  49. //  Description:
  50. //        Update the state of the option box UI to reflect the option values.
  51. //
  52. //  Input Arguments:
  53. //      parent               - Top level parent layout of the option box UI.
  54. //                             Required so that UI object names can be 
  55. //                             successfully resolved.
  56. //
  57. //    forceFactorySettings     - Whether the option values should be set to
  58. //                             default values.
  59. //
  60. //  Return Value:
  61. //      None.
  62. //
  63. global proc createClipTimeWarpSetup (string $parent, int $forceFactorySettings)
  64. {
  65.     // Retrieve the option settings.
  66.     setOptionVars( $forceFactorySettings );
  67.  
  68.     setParent $parent;
  69.     
  70.     int $warpEnabled = `optionVar -query createClipTimeWarpOptBox`;
  71.     switch ($warpEnabled) {
  72.         case 1:
  73.             radioButtonGrp -e -sl 1 createClipTimeWarpEnabled;
  74.             break;
  75.         case 2:
  76.             radioButtonGrp -e -sl 1 createClipTimeWarpDisabled;
  77.             break;
  78.     }
  79. }
  80.  
  81. //
  82. //  Procedure Name:
  83. //      createClipTimeWarpCallback
  84. //
  85. //  Description:
  86. //        Update the option values with the current state of the option box UI.
  87. //
  88. //  Input Arguments:
  89. //      parent - Top level parent layout of the option box UI.  Required so
  90. //               that UI object names can be successfully resolved.
  91. //
  92. //        doIt    - Whether the command should execute.
  93. //
  94. //        clipEd    - The name of the Clip Editor.
  95. //
  96. //  Return Value:
  97. //      None.
  98. //
  99. global proc createClipTimeWarpCallback (string $parent, 
  100.                                         int $doIt, string $clipEd)
  101. {
  102.     setParent $parent;
  103.  
  104.     if (`radioButtonGrp -q -sl createClipTimeWarpEnabled`) {
  105.         optionVar -intValue createClipTimeWarpOptBox 1;
  106.     } else {
  107.         optionVar -intValue createClipTimeWarpOptBox 2;
  108.     }
  109.  
  110.     if ($doIt)
  111.         performCreateClipTimeWarp false $clipEd;
  112. }
  113.  
  114.  
  115. proc string createClipTimeWarpWidgets( string $parent )
  116. {
  117.     setParent $parent;
  118.     
  119.     string $tabForm = `columnLayout -adj true`;
  120.  
  121.         radioButtonGrp -numberOfRadioButtons 1
  122.             -label "Time Warp"
  123.             -label1 "Enabled Time Warp Curve"
  124.             createClipTimeWarpEnabled;
  125.  
  126.         radioButtonGrp -numberOfRadioButtons 1
  127.             -label1 "Disabled Time Warp Curve"
  128.             -shareCollection createClipTimeWarpEnabled
  129.             createClipTimeWarpDisabled;
  130.  
  131.     return $tabForm;
  132. }
  133.  
  134. global proc createClipTimeWarpOptions (string $clipEd)
  135. {
  136.     string $commandName = "createClipTimeWarp";
  137.  
  138.     // Build the option box "methods"
  139.     //
  140.     string $callback = ($commandName + "Callback");
  141.     string $setup = ($commandName + "Setup");
  142.  
  143.     //    Get the option box.
  144.     //
  145.     //  The value returned is the name of the layout to be used as
  146.     //    the parent for the option box UI.
  147.     //
  148.     string $layout = getOptionBox();
  149.     setParent $layout;
  150.  
  151.     setOptionBoxCommandName($commandName);
  152.  
  153.     setUITemplate -pushTemplate DefaultTemplate;
  154.     waitCursor -state 1;
  155.     tabLayout -scr true -tv false;    // To get the scroll bars
  156.  
  157.     string $parent = `columnLayout -adjustableColumn 1`;
  158.  
  159.     createClipTimeWarpWidgets $parent;
  160.  
  161.     waitCursor -state 0;
  162.     setUITemplate -popTemplate;
  163.  
  164.     //    'Apply' button.
  165.     //
  166.     string $applyBtn = getOptionBoxApplyBtn();
  167.     button -edit
  168.         -label "Create Time Warp"
  169.         -command ($callback + " " + $parent + " " + 1 + " \"" + $clipEd + "\"")
  170.         $applyBtn;
  171.  
  172.     //    'Save' button.
  173.     //
  174.     string $saveBtn = getOptionBoxSaveBtn();
  175.     button -edit 
  176.         -command ($callback + " " + $parent + " " + 0 + "\"" + $clipEd + "\"; hideOptionBox")
  177.         $saveBtn;
  178.  
  179.     //    'Reset' button.
  180.     //
  181.     string $resetBtn = getOptionBoxResetBtn();
  182.     button -edit 
  183.         -command ($setup + " " + $parent + " " + 1)
  184.         $resetBtn;
  185.  
  186.     //    Set the option box title.
  187.     //
  188.     setOptionBoxTitle("Clip Time Warp Options");
  189.  
  190.     //    Customize the 'Help' menu item text.
  191.     //
  192.     setOptionBoxHelpTag( "TimeWarp" );
  193.  
  194.     //    Set the current values of the option box.
  195.     //
  196.     eval (($setup + " " + $parent + " " + 0));    
  197.     
  198.     //    Show the option box.
  199.     //
  200.     showOptionBox();
  201. }
  202.  
  203. //
  204. //  Procedure Name:
  205. //      assembleCmd
  206. //
  207. //  Description:
  208. //        Construct the command that will apply the option box values.
  209. //
  210. //  Input Arguments:
  211. //      The name of the clip editor used to call this option box.
  212. //
  213. //  Return Value:
  214. //      None.
  215. //
  216. proc string assembleCmd(string $clipEd)
  217. {
  218.     string $cmd;
  219.  
  220.     setOptionVars(false);
  221.  
  222.     int $enableWarp = true;
  223.     if (`optionVar -query createClipTimeWarpOptBox` != 1) {
  224.         $enableWarp = false;
  225.     }
  226.  
  227.     if (size($clipEd) == 0) {
  228.         error ("Could not find the clipEditor.");
  229.     }
  230.  
  231.     string $selected[] = `clipEditor -q -sc $clipEd`;
  232.     int $nSelected = size($selected);
  233.     if ($nSelected < 2) {
  234.         error ("Select a clip for time warp creation.");
  235.     }
  236.  
  237.     string $clipArray = "{";
  238.  
  239.     int $ii = 0;
  240.     int $nAdded = 0;
  241.     string $pre = "";
  242.     for ($ii = 0; $ii < $nSelected; $ii++) {
  243.         string $scheduler = $selected[$ii++];
  244.         int $index = $selected[$ii];
  245.  
  246.         string $clip = `clipSchedule -ci $index -q -n $scheduler`;
  247.         if (size($clip) == 0) {
  248.             continue;
  249.         }
  250.  
  251.         if ($nAdded++ > 0) {
  252.             $pre = ",";
  253.         }
  254.         $clipArray += ($pre+"\"" + $clip + "\"");
  255.     }
  256.  
  257.     $clipArray += "}";
  258.  
  259.     string $cmd = 
  260.         ("doCreateClipTimeWarp( "+$clipArray+", "+$enableWarp+");");
  261.  
  262.     return $cmd;
  263. }
  264.  
  265. //
  266. //  Procedure Name:
  267. //      performCreateClipTimeWarp
  268. //
  269. //  Description:
  270. //        Adds a time warp curve to the clip.
  271. //
  272. //  Input Arguments:
  273. //      0 - Execute the command.
  274. //      1 - Show the option box dialog.
  275. //      2 - Return the command.
  276. //
  277. //  Return Value:
  278. //      None.
  279. //
  280. global proc string performCreateClipTimeWarp (int $action, string $clipEd)
  281. {
  282.     string $cmd = "";
  283.  
  284.     switch ($action) {
  285.  
  286.         //    Execute the command.
  287.         //
  288.         case 0:
  289.             //    Retrieve the option settings
  290.             //
  291.             setOptionVars(false);
  292.  
  293.             //    Get the command.
  294.             //
  295.             $cmd = `assembleCmd($clipEd)`;
  296.  
  297.             //    Execute the command with the option settings.
  298.             //
  299.             if ($cmd != "")
  300.                 eval($cmd);
  301.             break;
  302.  
  303.         //    Show the option box.
  304.         //
  305.         case 1:
  306.             createClipTimeWarpOptions($clipEd);
  307.             break;
  308.         case 2:
  309.             //    Get the command.
  310.             //
  311.             $cmd = `assembleCmd($clipEd)`;
  312.     }
  313.     return $cmd;
  314. }
  315.  
  316.